<?php

    session_start();

    $email = $_GET['email'];
    $password = $_GET['password'];

    $connection = mysql_connect ('localhost', 'zorik_if039', '9731')
    or die ('Unable to connect!');
    mysql_select_db('zorik_if039') or die (mysql_error());
    mysql_query("set character_set_client='utf8'"); 
    mysql_query("set character_set_server='utf8'"); 
    mysql_query("set character_set_results='utf8'"); 
    mysql_query("set collation_connection='utf8_unicode_ci'");
    $query = "SELECT * FROM user where email='$email' and password='$password'";
    $res = mysql_query($query) or die(mysql_error());
    $num_row = mysql_num_rows($res);
    $row=mysql_fetch_array($res);
    if( $num_row >=1 ) { 
        $_SESSION['user_id']=$row['id'];
        $login['logged'] = true;
        $login['user_id'] = $row['id'];
        $userList = (object) array('error' => 0, 'errormessage' => '', 'data' => $login);
    } else {
        $_SESSION['user_id']='';
        $login['logged'] = false;
        $login['user_id'] = -1;
        $userList = (object) array('error' => 0, 'errormessage' => '', 'data' => $login);
    }
    echo json_encode($userList);

?>